<template>
  <div>
    <el-dialog title="新增立项信息" :visible.sync="showFurther" width="60%" :before-close="closeAll" :close-on-click-modal="false">
      <el-form :model="data" :rules="modelRules" ref="firstStep" label-width="150px" size="small" label-position="right">
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目" prop="bizId">
              <el-select v-model="data.bizId" placeholder="请选择" clearable prop="bizId" @change="bizIdChange">
                <el-option v-for="(item, index) in typeList" :key="index" :label="item.projectName" :value="item.projectKey"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="事项" prop="chargeItemType">
              <el-select v-model="data.chargeItemType" placeholder="请选择" clearable @change="mattersChange" prop="chargeItemType">
                <el-option v-for="item in chargeItemTypeList" :key="item.key" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" :justify="'end'">
          <el-button @click="closeAll" round> 取消 </el-button>
          <el-button @click="next1('firstStep')" round> 下一步 </el-button>
        </el-row>
      </el-form>
    </el-dialog>
    <!-- 弹框 -->
    <el-dialog title="填写追加信息" :visible.sync="showSecurityStaff" width="60%" :before-close="closeAll" :close-on-click-modal="false">
      <el-form :model="data" :rules="modelRules" ref="form2" label-width="150px" size="small" label-position="right">
        <el-row>
          <el-col :span="12">
            <el-form-item label="事项类型">
              <el-select disabled v-model="data.chargeItemType" placeholder="请选择" clearable>
                <el-option v-for="(item, index) in chargeItemTypeList" :key="index" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="事项名称" prop="chargeItemName">
              <el-input v-model="data.chargeItemName" placeholder="请输入事项名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="追加成本" v-if="!editTotal" prop="totalCost">
              <el-input type="number" v-model="data.totalCost" :step="10" placeholder="请输入金额"></el-input>
            </el-form-item>
            <el-form-item label="追加成本" v-else>
              <el-input disabled type="number" v-model="totalAmount" :step="10" placeholder="自动生成"></el-input>
            </el-form-item>
          </el-col>
          <!-- 保安，保洁 -->
          <template v-if="model.chargeItemCloudDto.chargeItemType == 1 || model.chargeItemCloudDto.chargeItemType == 2">
            <el-col :span="12">
              <el-form-item label="付款方式" prop="paymentMethod">
                <el-select v-model="data.paymentMethod" :placeholder="'请选择'">
                  <el-option v-for="item in paymentMethod" :key="item.key" :label="item.value" :value="item.key" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="首次付款时间" prop="firstPaymentDate">
                <el-date-picker v-model="data.firstPaymentDate" type="date" placeholder="请选择日期"> </el-date-picker>
              </el-form-item>
            </el-col>
          </template>
          <!-- 日常日耗品 -->
          <template v-if="model.chargeItemCloudDto.chargeItemType == 3">
            <el-col :span="12" v-for="item in model.forecastItemListCloudDto" :key="item.month">
              <el-form-item :label="item.month + '月追加预估金额'" label-width="160px">
                <el-input type="number" v-model="item.paymentAmount" :min="0" :step="10" placeholder="请输入追加预估金额"></el-input>
              </el-form-item>
            </el-col>
          </template>
          <!-- 保养，新增 -->
          <template v-if="model.chargeItemCloudDto.chargeItemType == 4 || model.chargeItemCloudDto.chargeItemType == 9 || model.chargeItemCloudDto.chargeItemType == 14">
            <el-col :span="12">
              <el-form-item label="事项内容" prop="chargeItemDesc">
                <el-input v-model="data.chargeItemDesc" :placeholder="'请填写事项内容'"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关联设备设施" prop="linkedDevice">
                <el-select v-model="data.linkedDevice" :placeholder="'请选择关联设备设施'" @change="linkedDeviceChange">
                  <el-option v-for="item in linkedDevice" :key="item.id" :label="item.name" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
            <div v-if="model.billConfigCloudDto.linkedDevice == 0">
              <el-col :span="12">
                <el-form-item label="选择子系统" prop="system">
                  <el-select v-model="data.system" :placeholder="'请选择子系统'" @change="systemChange">
                    <el-option v-for="item in system" :key="item.primaryKey" :label="item.systemName" :value="item.primaryKey" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="选择设备" prop="device">
                  <el-select v-model="data.device" :placeholder="'请选择设备'">
                    <el-option v-for="item in device" :key="item.primaryKey" :label="item.deviceName" :value="item.primaryKey" />
                  </el-select>
                </el-form-item>
              </el-col>
            </div>
            <el-col :span="12" v-else>
              <el-form-item label="选择设施" prop="facility">
                <el-select v-model="data.facility" :placeholder="'请选择设施'">
                  <el-option v-for="item in facility" :key="item.primaryKey" :label="item.stationName" :value="item.primaryKey" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="选择功能分区" prop="spacePartition">
                <el-select v-model="data.spacePartition" :placeholder="'请选择功能分区'">
                  <el-option v-for="item in spacePartition" :key="item.primaryKey" :label="item.partitionName" :value="item.primaryKey" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="选择楼层" prop="floor">
                <el-select v-model="data.floor" :placeholder="'请选择楼层'">
                  <el-option v-for="item in floor" :key="item.primaryKey" :label="item.floorName" :value="item.primaryKey" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否资本性支出" prop="ifCapitalPayment">
                <el-select v-model="data.ifCapitalPayment" :placeholder="'请选择是否资本性支出'">
                  <el-option v-for="item in ifCapitalPayment" :key="item.id" :label="item.name" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关联资本性支出类型" label-width="180px" prop="capitalPaymentType">
                <el-select v-model="data.capitalPaymentType" :placeholder="'请选择关联资本性支出类型'">
                  <el-option v-for="item in capitalPaymentType" :key="item.id" :label="item.name" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="付款计划">
                <span class="addSpan" @click="addPaymentPlan">增加</span>
              </el-form-item>
            </el-col>
            <div v-for="(item, index) in model.paymentItemListCloudDto" :key="index">
              <el-col :span="11">
                <el-form-item label="付款时间">
                  <el-date-picker v-model="item.paymentDate" type="date" placeholder="请选择付款时间"> </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label="付款金额">
                  <el-input type="number" v-model="item.paymentAmount" :step="10" placeholder="请选择付款金额"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="2">
                <span class="text-del" @click="delPaymentPlan(index)">删除</span>
              </el-col>
            </div>
          </template>

          <!-- 保安，保洁 -->
          <template v-if="model.chargeItemCloudDto.chargeItemType == 1 || model.chargeItemCloudDto.chargeItemType == 2">
            <el-col :span="12">
              <el-form-item label="开始时间" prop="rentStartDate">
                <el-date-picker v-model="data.rentStartDate" type="date" placeholder="请选择开始时间"> </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="结束时间" prop="rentEndDate">
                <el-date-picker v-model="data.rentEndDate" type="date" placeholder="请选择结束时间"> </el-date-picker>
              </el-form-item>
            </el-col>
          </template>
          <el-col :span="24">
            <el-form-item label="附件">
              <el-upload class="upload-demo" :show-file-list="false" action="no" :http-request="event => beforeupload(event.file)">
                <el-button type="primary" plain class="addSpan" style="margin-right: 10px" size="mini">上传附件</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col v-if="model.businessAttachmentMapListCloudDto.length > 0">
            <el-form-item label="">
              <el-button type="text" style="margin-right: 10px" v-for="(file, i) in model.businessAttachmentMapListCloudDto" :key="i" @click="DownFile(file)">{{ file.fileTitle }} </el-button>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="说明">
              <el-input autosize v-model="model.billConfigCloudDto.configDesc" placeholder="请输入" clearable></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex" :justify="'end'">
          <el-button @click="save" round> 保存 </el-button>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { uploadPhoto } from '@/api';
import Api from '../api/doWork';
import { projectList } from '@/api';
export default {
  components: {},

  data() {
    return {
      showFurther: false,
      showSecurityStaff: false,
      showPurchase: false,
      showInformation: false,
      //新增立项
      model: {
        chargeItemCloudDto: {
          bizType: '2',
          bizId: null,
          chargeItemType: null,
          chargeItemName: null,
          chargeItemDesc: null,
          chargeItemGroup: null,
        },
        billConfigCloudDto: {
          configType: '2',
          totalCost: null,
          paymentMethod: null,
          firstPaymentDate: null,
          rentStartDate: null,
          rentEndDate: null,
          configDesc: null,
          linkedDevice: '0',
          system: null,
          device: null,
          facility: null,
          spacePartition: null,
          floor: null,
          ifCapitalPayment: null,
          capitalPaymentType: null,
        },
        businessAttachmentMapListCloudDto: [],
        forecastItemListCloudDto: [
          {
            paymentAmount: null,
            month: '1',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '2',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '3',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '4',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '5',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '6',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '7',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '8',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '9',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '10',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '11',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '12',
            paymentType: '0',
          },
        ], //预估金额
        paymentItemListCloudDto: [],
        planInfoItemBatch: {
          chargeItemName: null,
          chargeItemType: null,
          chargeItemDesc: null,
          chargeItemGroup: null,
          planItemType: '2',
          projectKey: null,
        },
      },
      modelRules: {
        bizId: [{ required: true, message: '请选择新增项目', trigger: 'change' }],
        chargeItemType: [{ required: true, message: '请选择事项', trigger: 'change' }],
        chargeItemName: [{ required: true, message: '请输入事项', trigger: 'blur' }],
        totalCost: [{ required: true, message: '请输入金额', trigger: 'blur' }],
        paymentMethod: [{ required: true, message: '请选择', trigger: 'change' }],
        firstPaymentDate: [{ type: 'date', required: true, message: '请选择日期', trigger: 'change' }],
        forecastItemListCloudDto: [{ required: true, message: '请输入预估金额', trigger: 'blur' }],
        chargeItemDesc: [{ required: true, message: '请填写事项内容', trigger: 'blur' }],
        linkedDevice: [{ required: true, message: '请选择关联设备设施', trigger: 'change' }],
        system: [{ required: true, message: '请选择子系统', trigger: 'change' }],
        device: [{ required: true, message: '请选择设备', trigger: 'change' }],
        facility: [{ required: true, message: '请选择设施', trigger: 'change' }],
        spacePartition: [{ required: true, message: '请选择功能分区', trigger: 'change' }],
        floor: [{ required: true, message: '请选择楼层', trigger: 'change' }],
        ifCapitalPayment: [{ required: true, message: '请选择是否资本行支出', trigger: 'change' }],
        capitalPaymentType: [{ required: true, message: '请选择关联资本性支出类型', trigger: 'change' }],
        paymentDate: [{ type: 'date', required: true, message: '请选择付款时间', trigger: 'change' }],
        paymentAmount: [{ required: true, message: '请输入付款金额', trigger: 'blur' }],
        rentStartDate: [{ type: 'date', required: true, message: '请选择时间', trigger: 'change' }],
        rentEndDate: [{ type: 'date', required: true, message: '请选择时间', trigger: 'change' }],
      },
      data: {
        bizId: null,
        chargeItemType: null,
        chargeItemName: null,
        totalCost: null,
        paymentMethod: null,
        firstPaymentDate: null,
        rentStartDate: null,
        rentEndDate: null,
        chargeItemDesc: null,
        linkedDevice: null,
        system: null,
        device: null,
        facility: null,
        spacePartition: null,
        floor: null,
        ifCapitalPayment: null,
        capitalPaymentType: null,
      },
      typeList: [], //新增项目列表
      //事项列表
      chargeItemTypeList: [
        {
          name: '保安人员费用',
          id: '1',
        },
        {
          name: '保洁人员费用',
          id: '2',
        },
        {
          name: '日常易耗品',
          id: '3',
        },
        {
          name: '保养',
          id: '4',
        },
        {
          name: '资本性支出',
          id: '9',
        },
        {
          name: '市场运营费',
          id: '14',
        },
      ],
      paymentMethod: [], //付款计划
      linkedDevice: [
        {
          name: '设备',
          id: '0',
        },
        {
          name: '设施',
          id: '1',
        },
      ], //关联设备设施
      system: [], //子系统
      device: [], //设备
      facility: [], //设施
      spacePartition: [], //功能分区
      floor: [], //楼层
      ifCapitalPayment: [
        {
          id: 1,
          name: '是',
        },
        {
          id: 0,
          name: '否',
        },
      ], //是否资本性支出
      capitalPaymentType: [
        {
          name: '项目更新改造、店面提升',
          id: '0',
        },
        {
          name: '设备更新、大中修',
          id: '1',
        },
        {
          name: '屋面防水工程',
          id: '2',
        },
        {
          name: '大额设备设施损坏',
          id: '3',
        },
      ], //关联资本性支出类型
    };
  },
  mounted() {
    this.getProjectList();
    this.getPaymentMethod();
  },
  methods: {
    checkTheAssignment() {
      if (this.editTotal) {
        this.model.billConfigCloudDto.totalCost = this.totalAmount + '';
      } else {
        this.model.billConfigCloudDto.totalCost = this.data.totalCost;
      }
      this.model.chargeItemCloudDto.bizId = this.data.bizId;
      this.model.chargeItemCloudDto.chargeItemType = this.data.chargeItemType;
      this.model.chargeItemCloudDto.chargeItemName = this.data.chargeItemName;
      this.model.chargeItemCloudDto.chargeItemDesc = this.data.chargeItemDesc;
      this.model.billConfigCloudDto.paymentMethod = this.data.paymentMethod;
      this.model.billConfigCloudDto.firstPaymentDate = this.data.firstPaymentDate;
      this.model.billConfigCloudDto.rentStartDate = this.data.rentStartDate;
      this.model.billConfigCloudDto.rentEndDate = this.data.rentEndDate;
      this.model.billConfigCloudDto.linkedDevice = this.data.linkedDevice;
      this.model.billConfigCloudDto.system = this.data.system;
      this.model.billConfigCloudDto.device = this.data.device;
      this.model.billConfigCloudDto.facility = this.data.facility;
      this.model.billConfigCloudDto.spacePartition = this.data.spacePartition;
      this.model.billConfigCloudDto.floor = this.data.floor;
      this.model.billConfigCloudDto.ifCapitalPayment = this.data.ifCapitalPayment;
      this.model.billConfigCloudDto.capitalPaymentType = this.data.capitalPaymentType;
    },
    linkedDeviceChange(val) {
      this.model.billConfigCloudDto.linkedDevice = val;
    },
    // 取消
    closeAll() {
      this.showFurther = false;
      this.showSecurityStaff = false;
      this.init();
    },
    next1(form) {
      this.$refs[form].validate(async isOK => {
        if (isOK) {
          this.showFurther = false;
          this.showSecurityStaff = true;
        }
      });
    },
    // 确定
    async save() {
      this.$refs.form2.validate(async valid => {
        this.checkTheAssignment();
        if (this.model.chargeItemCloudDto.chargeItemType == '4' || this.model.chargeItemCloudDto.chargeItemType == '9' || this.model.chargeItemCloudDto.chargeItemType == '14') {
          if (this.model.paymentItemListCloudDto.length == 0) {
            this.$message.warning('请增加付款计划');
            return;
          }
        }
        if (this.model.chargeItemCloudDto.chargeItemType == 3) {
          for (let i = 0; i < this.model.forecastItemListCloudDto.length; i++) {
            if (this.model.forecastItemListCloudDto[i].paymentAmount == null || this.model.forecastItemListCloudDto[i].paymentAmount == '') {
              this.$message.warning('请输入预估金额');
              return;
            }
          }
        }
        if (valid) {
          if (this.model.chargeItemCloudDto.chargeItemType == 9) {
            this.model.chargeItemCloudDto.chargeItemGroup = '1';
            this.model.planInfoItemBatch.chargeItemGroup = '1';
          } else if (this.model.chargeItemCloudDto.chargeItemType == 1 || this.model.chargeItemCloudDto.chargeItemType == 2 || this.model.chargeItemCloudDto.chargeItemType == 3 || this.model.chargeItemCloudDto.chargeItemType == 4) {
            this.model.chargeItemCloudDto.chargeItemGroup = '2';
            this.model.planInfoItemBatch.chargeItemGroup = '2';
          } else if (this.model.chargeItemCloudDto.chargeItemType == 14) {
            this.model.chargeItemCloudDto.chargeItemGroup = '4';
            this.model.planInfoItemBatch.chargeItemGroup = '4';
          }
          this.model.planInfoItemBatch.chargeItemDesc = this.model.chargeItemCloudDto.chargeItemDesc;
          this.model.planInfoItemBatch.chargeItemName = this.model.chargeItemCloudDto.chargeItemName;
          this.model.planInfoItemBatch.chargeItemType = this.model.chargeItemCloudDto.chargeItemType;
          this.model.chargeItemCloudDto.bizType = '2';
          if (this.model.chargeItemCloudDto.chargeItemType == 1 || this.model.chargeItemCloudDto.chargeItemType == 2 || this.model.chargeItemCloudDto.chargeItemType == 4) {
            this.model.forecastItemListCloudDto = [];
          }
          const res = await Api.additionalCreate(this.model);
          if (res && res.success) {
            this.$message.success('保存成功');
            this.closeAll();
          } else {
            this.$message.warning('请重试');
          }
        } else {
          return false;
        }
      });
    },
    async getProjectList() {
      const res = await projectList();
      this.typeList = res.rows || []
    },
    async getPaymentMethod() {
      const res = await Api.constantPaymentMethod();
      this.paymentMethod = res.paymentMethod;
    },
    beforeupload(file, a) {
      uploadPhoto(file).then(res => {
        this.model.businessAttachmentMapListCloudDto = [{ fileUrl: res.data.rows[0].url, fileTitle: res.data.rows[0].originalName, fileId: res.data.rows[0].key }];
        this.$message.success('上传成功');
      });
    },
    addPaymentPlan() {
      this.model.paymentItemListCloudDto.push({
        paymentDate: null,
        paymentAmount: null,
        paymentType: '3',
      });
    },
    delPaymentPlan(index) {
      this.model.paymentItemListCloudDto.splice(index, 1);
    },
    mattersChange(val) {
      if (val === '') return;
      let cur = this.chargeItemTypeList.find(item => {
        return item.id === val;
      });

      this.model.chargeItemCloudDto.chargeItemType = cur.id;
      this.model.chargeItemCloudDto.chargeItemName = cur.name;
      this.data.chargeItemName = cur.name;
      this.model.planInfoItemBatch.chargeItemName = cur.name;
      this.model.planInfoItemBatch.chargeItemType = cur.id;
    },
    init() {
      this.model = {
        chargeItemCloudDto: {
          bizType: '2',
          bizId: null,
          chargeItemType: null,
          chargeItemName: null,
          chargeItemDesc: null,
          chargeItemGroup: null,
        },
        billConfigCloudDto: {
          configType: '2',
          totalCost: null,
          paymentMethod: null,
          firstPaymentDate: null,
          rentStartDate: null,
          rentEndDate: null,
          configDesc: null,
          linkedDevice: '0',
          system: null,
          device: null,
          facility: null,
          spacePartition: null,
          floor: null,
          ifCapitalPayment: null,
          capitalPaymentType: null,
        },
        businessAttachmentMapListCloudDto: [],
        forecastItemListCloudDto: [
          {
            paymentAmount: null,
            month: '1',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '2',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '3',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '4',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '5',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '6',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '7',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '8',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '9',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '10',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '11',
            paymentType: '0',
          },
          {
            paymentAmount: null,
            month: '12',
            paymentType: '0',
          },
        ], //预估金额
        paymentItemListCloudDto: [],
        planInfoItemBatch: {
          projectKey: null,
          chargeItemName: null,
          chargeItemType: null,
          chargeItemDesc: null,
          chargeItemGroup: null,
          planItemType: '2',
        },
      };
      this.data = {
        bizId: null,
        chargeItemType: null,
        chargeItemName: null,
        totalCost: null,
        paymentMethod: null,
        firstPaymentDate: null,
        rentStartDate: null,
        rentEndDate: null,
        chargeItemDesc: null,
        linkedDevice: null,
        system: null,
        device: null,
        spacePartition: null,
        floor: null,
        ifCapitalPayment: null,
        capitalPaymentType: null,
      };
    },
    DownFile(file) {
      window.open(file.fileUrl);
    },
    bizIdChange(val) {
      this.model.chargeItemCloudDto.bizId = val;
      this.model.planInfoItemBatch.projectKey = val;
      this.getDictionary(val);
    },
    async getDictionary(projectKey = null, systemKey = null) {
      const res = await Api.dictionary({
        projectKey,
        systemKey,
      });
      if (res && res.success) {
        if (!systemKey) {
          //楼层
          this.floor = res.businessFloor;
          //设施
          if (res.baseStation && res.baseStation.success) {
            this.facility = res.baseStation.rows;
          }
          //分区
          if (res.spacePartition && res.spacePartition.success) {
            this.spacePartition = res.spacePartition.rows;
          }
          //子系统
          if (res.systemInfo && res.systemInfo.success) {
            this.system = res.systemInfo.rows;
          }
        } else {
          //设备deviceInfo
          if (res.deviceInfo && res.deviceInfo.success) {
            this.device = res.deviceInfo.rows;
          }
        }
      }
    },
    systemChange(val) {
      this.getDictionary(this.model.chargeItemCloudDto.bizId, val);
    },
  },
  computed: {
    totalAmount() {
      if (this.model.chargeItemCloudDto.chargeItemType == 3) {
        return this.model.forecastItemListCloudDto.reduce((total, item) => {
          console.log(total);
          if (item.paymentAmount == null) {
            return total;
          } else {
            return total + parseInt(item.paymentAmount);
          }
        }, 0);
      }
      if (this.model.chargeItemCloudDto.chargeItemType == 4 || this.model.chargeItemCloudDto.chargeItemType == 9 || this.model.chargeItemCloudDto.chargeItemType == 14) {
        if (this.model.paymentItemListCloudDto.length != 0) {
          return this.model.paymentItemListCloudDto.reduce((total, item) => {
            console.log(total);
            if (item.paymentAmount == null) {
              return total;
            } else {
              return total + parseInt(item.paymentAmount);
            }
          }, 0);
        }
      }
    },
    editTotal() {
      if (this.model.chargeItemCloudDto.chargeItemType == 1 || this.model.chargeItemCloudDto.chargeItemType == 2) return false;
      else return true;
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  .el-dialog__header {
    background: #444444;
  }
}
::v-deep .el-button.is-round {
  background-color: #444444;
  color: #fff;
}
::v-deep .payMoney .el-form-item__content {
  display: flex;
  .delSpan {
    cursor: pointer;
    color: #33b5ff;
    width: 50px;
    text-align: right;
  }
}
.el-col {
  height: 50px;
}
.addSpan {
  cursor: pointer;
  color: #33b5ff;
}
.textSpan {
  color: #bf4747;
}
.text-del {
  cursor: pointer;
  color: #33b5ff;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
